package com.wisdomparking.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wisdomparking.bean.EcdemicParking;
import com.wisdomparking.bean.simple.SimpleEcdemicParking;
import com.wisdomparking.dao.EcdemicParkingDao;
import com.wisdomparking.service.EcdemicParkingService;

@Service
public class EcdemicParkingServiceImpl implements EcdemicParkingService {
	
	@Autowired EcdemicParkingDao ecdemicParkingDao;
	
	// 添加
	@Override
	public boolean addEcdemicParking(EcdemicParking en, boolean sign) {
		int i = 0;
		
		try {

			if (sign) {
				i = ecdemicParkingDao.insert(en);
			} else {
				i = ecdemicParkingDao.insertSelective(en);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}

		return i == 1 ? true : false;
	}
	
	// 修改
	@Override
	public boolean updateEcdemicParking(EcdemicParking en, boolean sign) {
		int i = 0;

		try {

			if (sign) {
				i = ecdemicParkingDao.updateByPrimaryKey(en);
			} else {
				i = ecdemicParkingDao.updateByPrimaryKeySelective(en);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

		return i == 1 ? true : false;
	}
	
	// 删除
	@Override
	public boolean deleteEcdemicParkingById(Integer id) {
		
		return ecdemicParkingDao.deleteByPrimaryKey(id)==1?true:false;
	}
	
	// 查询
	@Override
	public EcdemicParking getEcdemicParking(Integer id) {
		
		return ecdemicParkingDao.selectByPrimaryKey(id);
	}
	
	// 查询
	@Override
	public EcdemicParking getEcdemicParkingByName(String name){
		
		return ecdemicParkingDao.selectByName(name);
	}
	
	// 获取对象列表
	@Override
	public List<EcdemicParking> getEcdemicParkingList(Map<String, Object> map) {
		
		return ecdemicParkingDao.getEcdemicParkingList(map);
	}
	
	// 获取记录总条数
	@Override
	public long getCountByEcdemicParking(Map<String, Object> map){
		
		return ecdemicParkingDao.getCountByEcdemicParking(map);
	}
	
	// 获取间单对象列表
	@Override
	public List<SimpleEcdemicParking> getDistanceEcdemicParking(Map<String, Object> map){
		return ecdemicParkingDao.getDistanceEcdemicParking(map);
	}
}
